<template>
    <el-dialog title="报告" :visible.sync="isDial" width="415px" class="seeReport" :before-close='closeDialog' id="div1">
        <span @click="toBack" class="toback"><i class="iconfont icon-fanhui"></i> 返回</span>
        <!-- <iframe :src="'http://192.168.1.72:8081/#/presentation?orderId='+orderId" frameborder="0" width="375" height="600"></iframe> -->
    </el-dialog>
</template>
<script>
export default {
    data(){
        return{
            isDial:false,
        }
    },
    methods:{
        toBack(){
            this.$router.go(-1);//返回上一层
        },
        closeDialog(){
            this.isDial=false
            this.url=''
        },
    },
    mounted(){
        this.$root.$on('seeReport',(data)=>{
            console.log(data)
            let orderId=data.orderId
            let url='http://green.jiagj.com/transfer/#/presentation?orderId='+orderId  //拼接路径
            var para=document.createElement("iframe"); //原生js创建节点
            para.src=url  // 节点属性赋值
            para.width='375'  
            para.height='600' 
            para.id='ifram'
            para.style='margin:-20px 20px 20px 20px'
            var element=document.getElementById("div1").firstChild; //获取id为div1节点的第一个子节点
            if(document.getElementById("ifram")){ //判断  是否有这个节点 是否存在
                var child=document.getElementById("ifram");
                element.removeChild(child); //将这个节点删除
            }
            console.log(element)
            element.appendChild(para); //将节点插入到  目标节点下面
            this.isDial=true
        })
    }
}
</script>
<style lang="less" scoped>
.seeReport{
    text-align: left;
    .toback{
        position: relative;
        top:-20px;
    }
}
</style>
